package project_model;

/**
 * ConcreteTest
 *
 * @author Syzer
 * @Description 装饰器模式
 * @Date 2021/7/9 14:59
 */
public class ConcreteTest {

    private interface Component {
        void show();
    }

    private static class ComponentImpl implements Component {
        @Override
        public void show() {
            System.out.println("显示");
        }
    }

    private static class Decorator implements Component {
        private Component component;

        public Decorator(Component component) {
            this.component = component;
        }

        @Override
        public void show() {
            component.show();
        }
    }

    private static class ConcreteDecorator extends Decorator {
        private Component component;

        public ConcreteDecorator(Component component) {
            super(component);
        }

        @Override
        public void show() {
            super.show();
            postShow();
        }

        public void postShow() {
            System.out.println("显示完增强");
        }
    }

    public static void main(String[] args) {
        ConcreteDecorator concreteDecorator = new ConcreteDecorator(new ComponentImpl());
        concreteDecorator.show();
    }
}
